package com.lnt.java.lambda;

import com.lnt.java.entity.Model;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class LambdaTest {

    public static void main(String[] args) {
        stream();
    }

    private static void stream(){
        List<Model> list1 = new ArrayList<Model>();
        List<Model> list2 = new ArrayList<Model>();
        for(int i = 0;i<5;i++){
            Model model = new Model();
            model.setId(i);
            model.setName("test" + i);
            model.setSeat("seat:" + i);
            list1.add(model);
        }
        String[] seats = {"seat:2","seat:3"};
        for (int i = 3 ; i < 6 ; i++){
            Model model = new Model();
            model.setId(i);
            model.setName("test" + i);
            model.setSeat("seat:" + i);
            list2.add(model);
        }

        List<String> strings = Arrays.asList(seats);
        list1.stream().forEach(model -> {
            if(strings.contains(model.getSeat())){
                model.setName("x");
            }else {
                model.setName("y");
            }
        });
        System.out.println(list1);
    }
}
